package com.lc.afbx.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lc.afbx.BaseApplication;
import com.lc.afbx.R;
import com.lc.afbx.conn.GetApiTeamInfomation;
import com.zcx.helper.bound.BoundViewHelper;

import java.util.List;

/**
 * Created by Administrator on 2016/8/6.
 */
public class TeamChooseListAdapter extends BaseAdapter {

    private Context context;
    private LayoutInflater inflater;
    private List<GetApiTeamInfomation.Data> dataList;

    public TeamChooseListAdapter(Context context, List<GetApiTeamInfomation.Data> dataList) {
        this.context = context;
        this.dataList = dataList;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;

        if (convertView == null) {

            convertView = BoundViewHelper.boundView(this, BaseApplication.ScaleScreenHelper.loadView((ViewGroup) inflater.inflate(R.layout.item_choose_team_list, null)));

            holder = new ViewHolder();

            holder.item_choose_team_title_tv = (TextView) convertView.findViewById(R.id.item_choose_team_title_tv);

            convertView.setTag(holder);

        } else {

            holder = (ViewHolder) convertView.getTag();
        }

        holder.item_choose_team_title_tv.setText(dataList.get(position).title);

        return convertView;
    }

    class ViewHolder {
        private TextView item_choose_team_title_tv;
    }
}
